<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
<div id="app">
    <p>姓氏："{{ firstName }}"</p>
    <p>名字："{{ lastName }}"</p>
    <p>姓名："{{ fullName }}"</p>
</div>



</body>
<script>
let app = new Vue({
    el: '#app',
    data: {
        firstName: 'Elon',
        lastName: 'Musk',
        fullName: 'Elon Musk'

    },
    watch: {
        firstName: function (val) {
            this.fullName = val + ' - ' + this.lastName
            console.log(this.fullName)
        },
        lastName: function (val) {
            this.fullName = this.firstName + ' , ' + val
            console.log(">>> "+this.fullName)
        }
    }
})


</script>
</html>
